home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
bbsutil
/
bsrc_250.zip
/
VERSION7.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-15
|
16KB
|
477 lines
/*--------------------------------------------------------------------------*/
/* */
/* */
/* ------------ Bit-Bucket Software, Co. */
/* \ 10001101 / Writers and Distributors of */
/* \ 011110 / Freely Available<tm> Software. */
/* \ 1011 / */
/* ------ */
/* */
/* (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
/* */
/* */
/* This module was adapted by Bill Andrus */
/* With the usual kibitzing by Vince Perriello */
/* */
/* BinkleyTerm Version7 Nodelist processing module */
/* */
/* */
/* For complete details of the licensing restrictions, please refer */
/* to the License agreement, which is published in its entirety in */
/* the MAKEFILE and BT.C, and also contained in the file LICENSE.250. */
/* */
/* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
/* BINKLEYTERM LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
/* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
/* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT BIT BUCKET */
/* SOFTWARE CO. AT ONE OF THE ADDRESSES LISTED BELOW. IN NO EVENT */
/* SHOULD YOU PROCEED TO USE THIS FILE WITHOUT HAVING ACCEPTED THE */
/* TERMS OF THE BINKLEYTERM LICENSING AGREEMENT, OR SUCH OTHER */
/* AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO. */
/* */
/* */
/* You can contact Bit Bucket Software Co. at any one of the following */
/* addresses: */
/* */
/* Bit Bucket Software Co. FidoNet 1:104/501, 1:343/491 */
/* P.O. Box 460398 AlterNet 7:491/0 */
/* Aurora, CO 80046 BBS-Net 86:2030/1 */
/* Internet f491.n343.z1.fidonet.org */
/* */
/* Please feel free to contact us at any time to share your comments about */
/* our software and/or licensing policies. */
/* */
/*--------------------------------------------------------------------------*/
/* Include this file before any other includes or defines! */
#include "includes.h"
/* This table has been modified to minimize searches */
char unwrk[] = " EANROSTILCHBDMUGPKYWFVJXZQ-'0123456789";
long btree (char *, void *, int (*)(void *, void *, int));
int get_ver7_info (unsigned long, ADDRP);
struct _ndx far *get7node(HFILE, unsigned long, struct _ndx far *);
void unpk(char *instr,char *outp,int many);
int addr_compare (void *, void *, int);
int name_compare (void *, void *, int);
extern void get_nodelist_name (ADDRP);
extern char *nodelist_base;
extern char *nodelist_name;
static char index_filename[260];
static int namelen;
static struct _ndx far *nodeidx = NULL; /* index file */
static struct _ndx far *noderef = NULL; /* index file */
int ver7find (ADDRP opus_addr, int have_boss_data)
{
long record;
ADDR found_addr;
have_boss_data = have_boss_data;
newnodedes.NetNumber = newnodedes.NodeNumber = 0;
get_nodelist_name (opus_addr); /* fill in nodelist.base */
index_filename[0] = '\0'; /* "null-terminated string*/
(void) strcpy (index_filename, net_info); /* take nodelist path */
(void) strcat (index_filename, nodelist_base); /* add in the file name*/
(void) strcat (index_filename, ".NDX"); /* add in the file ext */
record = btree (index_filename, (void *)opus_addr, addr_compare);
if (record == -1)
return (0);
else
return (get_ver7_info((unsigned long)record, &found_addr));
}
int addr_compare (void *key, void *desired, int len)
{
int k;
k = ((ADDRP)key)->Zone - ((ADDRP)desired)->Zone;
if (k)
return (k);
k = ((ADDRP)key)->Net - ((ADDRP)desired)->Net;
if (k)
return (k);
k = ((ADDRP)key)->Node - ((ADDRP)desired)->Node;
if (k)
return (k);
/*
* Node matches.
*
* The rule for points:
* 1) If len == 6, treat key value for Point as Zero.
* 2) Return comparison of key Point and desired Point.
*/
if (len == 6)
((ADDRP)key)->Point = 0;
return ((ADDRP)key)->Point - ((ADDRP)desired)->Point;
}
void opususer (char *name, ADDRP faddr)
{
char last_name_first[80];
char midname[80];
char *c, *p, *m;
long record;
faddr->Zone = faddr->Net = faddr->Node = faddr->Point = (unsigned int) -1;
faddr->Domain = NULL;
c = midname; /* Start of temp name buff */
p = name; /* Point to start of name */
m = NULL; /* Init pointer to space */
*c = *p++;
while (*c) /* Go entire length of name */
{
if (*c == ' ') /* Look for space */
m = c; /* Save location */
c++;
*c = *p++;
}
if (m != NULL) /* If we have a pointer, */
{
*m++ = '\0'; /* Terminate the first half */
(void) strcpy (last_name_first, m); /* Now copy the last name */
(void) strcat (last_name_first, ", "); /* Insert a comma and space */
(void) strcat (last_name_first, midname); /* Finally copy first half */
}
else (void) strcpy (last_name_first, midname);/* Use whole name otherwise */
(void) fancy_str (last_name_first); /* Get caps in where needed */
namelen = (int) strlen (last_name_first); /* Calc length now */
index_filename[0] = '\0'; /* "null-terminated string" */
if (nodelist_base == NULL)
get_nodelist_name (&my_addr); /* fill in nodelist.base */
(void) strcpy (index_filename, net_info); /* take nodelist path */
(void) strcat (index_filename, "SYSOP.NDX"); /* add in the file name */
record = btree (index_filename, (void *)last_name_first, name_compare);
if (record == -1)
return;
(void) get_ver7_info((unsigned long)record, faddr);
}
int name_compare (void *key, void *desired, int len)
{
return (strnicmp ((char *)key, (char *)desired, (unsigned int) min (namelen,len)));
}
/*
* General V7 nodelist engine. Used by both the by-node and by-sysop
* lookups.
*
* Thanks to Phil Becker for showing me how nice it looks in assembler.
* It helped me see how nice it could be in C.
*
* (I know, Phil, it's still nicer in assembler!)
*
*/
long